<?php
class PC4_Crud_ComTags extends PC4_Crud_Tabelas {
	
	public function __construct($config = null, $definition = null) {
		parent::__construct($config, $definition);
    	$tabela = $this->config['name'];
    	$alias = $this->getAlias($tabela);
		$this->addTabelas(array(
			$tabela . '_rel_' . $tabela . '_categorias rel' => array(
				'pk' => 'rel.id_' . $tabela,
				'fk' => $alias . '.id',
				'join' => 'left'
			),
			$tabela . '_categorias cat' => array(
				'pk' => 'cat.id',
				'fk' => 'rel.id_' . $tabela . '_categorias',
				'campos' => array('categorias' => 'GROUP_CONCAT(cat.nome)'),
				'join' => 'left'
			)
		));
		$this->addGroup($alias . '.id');
		
	}
	
}